package com.example.demo.controller;
import com.example.demo.model.Dk;
import com.example.demo.service.IDkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 董婷
 */

@Api(tags = "打卡管理")
@RestController
@RequestMapping("/swagger22")
public class dkController {
    @Autowired
    private IDkService dkService;
    @CrossOrigin
    @ApiOperation(value="对打卡记录的添加方法")
    @PostMapping("/insertdk")
    public int insertUser(@RequestBody Dk dk){
        System.out.println("进入记录打卡接口" );
        return dkService.insertDk(dk);
    }

    @PostMapping("/getAll")
    public List<Dk> getAllDk(@RequestBody Dk dk)
    {
        System.out.println("添加打卡记录查询");
        List<Dk> listDk=dkService.getAllDk(dk);
        return listDk;
    }
    @PostMapping("/editDk")
    public int EditDk(@RequestBody Dk dk){
        System.out.println("进入打卡记录修改方法");
        return dkService.updateDk(dk);
    }
    @GetMapping("/delDk")
    public int Delete(int dkid){
        System.out.println("进入删除打卡记录方法");
        int returnValues=0;
        if(dkid!=0){
            Dk dk=new Dk();
            dk.setDkid(dkid);
            returnValues=dkService.deleteDk(dk);
        }
        return returnValues;
    }

    @GetMapping("/getOne")
    public Dk getDk(int dkid){
        Dk dk=new Dk();
        System.out.println("进入单条查询打卡记录方法");
        if(dkid!=0){
            Dk dk1=new Dk();
            dk1.setDkid(dkid);
            dk=dkService.getDk(dk1);
            System.out.println("返回的数据集合为:"+dk.getYgid());
        }
        return dk;
    }








}
